package com.liuhx.service.impl;

import com.liuhx.entity.BrandEntity;
import com.liuhx.mapper.BrandMapper;
import com.liuhx.service.BrandService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by liuhx on 2017/6/21.
 */
@Service
public class BrandServiceImpl implements BrandService {
    @Resource
    BrandMapper brandMapper;
    @Override
    public List<BrandEntity> findBrand() {
        return brandMapper.getAll();
    }

    @Override
    public void insertBrands(List<BrandEntity> brandEntityList) {
        List<BrandEntity> brandEntities = brandMapper.findAllBrands();
        brandEntityList.removeAll(brandEntities);
        if(brandEntityList.size()>0) {
            brandMapper.insertBrands(brandEntityList);
        }
    }
}
